! function(e){
	"use strict";
	var t = document,
		n = {
			modules: {},
			status: {},
			timeout: 10,
			event: {}
		},
		o = function(){
			this.v = "1.0.0";
		},
		a = function(t){
//			console.log("zsxmlv hint:" + t);
		},
		r = function(){/*返回模块所在的目录+“/”*/
			var e = t.currentScript ? t.currentScript.src : function(){
				console.log("进入 r function")
				/**
				 * for 循环 初始化
				 * 	定义变量e、
				 *  n、t.scripts => 当前页面的所有脚本文件（数组）
				 *  r、o => 脚本文件的个数-1 => 即数组下标
				 * 
				 * ===========华=丽=分=割=线=====================
				 * HTML DOM readyState 属性 => 返回当前文档对象的状态(载入中...)
				 * uninitialized  => 还未开始载入
				 * loading 		  => 载入中
				 * interactive    => 已加载，文档与用户可以开始交互
				 * complete       => 载入完成
				 * ===========华=丽=分=割=线=====================
				 * 只要存在 “已加载”的脚本即返回true
				 */
				for(var e, n = t.scripts, o = n.length - 1, r = o; r > 0; r--){
					if("interactive" === n[r].readyState){
						e = n[r].src;
						break
					}
				}
				return e || n[o].src
			}();
			return e.substring(0, e.lastIndexOf("/") + 1);
		}(),
		/**
		 * u：模块对象
		 */
		u = {
			// jquery: 'modules/jquery'
		};
	/**
	 * @method cite
	 * @description 引用其他模块，相当于Layui的use
	 */
	o.prototype.cite = function(e, o, l){
		// navigator.platform：属性是一个只读的字符串，声明了运行浏览器的操作系统和（或）硬件平台。(e.g:Win32)
		function s(e, t) {
			var o = "PLaySTATION 3" === navigator.platform ? /^complete$/ : /^(complete|loaded)$/;
			("load" === e.type || o.test((e.currentTarget || e.srcElement).readyState)) && (n.modules[f] = t, d.removeChild(v), function r() {
				return ++m > 1e3 * n.timeout / 4 ? a(f + " is not a valid module") : void(n.status[f] ? c() : setTimeout(r, 4))
			}())
		}
		function c() {
			l.push(zs[f]), e.length > 1 ? y.cite(e.slice(1), o, l) : "function" == typeof o && o.apply(zs, l)
		}
		
		/**
		 * this对象==>zsxmlv
		 * p：如果“n”有“dir”属性,返回“n”的“dir”;没有,返回模块所在的目录
		 * d：返回head标签里的内容
		 * e：数组,需要使用到的模块js
		 */
		var y = this,
			p = n.dir = n.dir ? n.dir : r,
			d = t.getElementsByTagName("head")[0];
		e = "string" == typeof e ? [e] : e, window.jQuery && jQuery.fn.on && (y.each(e, function(t, n) {
			"jquery" === n && e.splice(t, 1)
		}), zs.jquery = zs.$ = jQuery);
		if(l = l || [], n.host = n.host || (p.match(/\/\/([\s\S]+?)\//) || ["//" + location.host + "/"])[0], 0 === e.length || u[f]) return c(), y;
		if(n.modules[f]) ! function g() {
			return ++m > 1e3 * n.timeout / 4 ? a(f + " is not a valid module") : void("string" == typeof n.modules[f] && n.status[f] ? c() : setTimeout(g, 4))
		}();
		var f = e[0], m = 0;
		if(!n.modules[f]){
			var v = t.createElement("script"),
				h = (u[f] ? p + "modules/" : /^\{\/\}/.test(y.modules[f]) ? "" : n.base || "") + (y.modules[f] || f) + ".js";
			h = h.replace(/^\{\/\}/, ""), v.async = !0, v.charset = "utf-8", v.src = h + function() {
				var e = n.version === !0 ? n.v || (new Date).getTime() : n.version || "";
				return e ? "?v=" + e : ""
			}(), d.appendChild(v), !v.attachEvent || v.attachEvent.toString && v.attachEvent.toString().indexOf("[native code") < 0 || i ? v.addEventListener("load", function(e) {
				s(e, h)
			}, !1) : v.attachEvent("onreadystatechange", function(e) {
				s(e, h)
			}), n.modules[f] = h
		}
		return y
	},o.prototype.cache = n,o.prototype.define = function(e, t){
		var o = this,
			r = "function" == typeof e,
			a = function() {
				var e = function(e, t) {
					zs[e] = t, n.status[e] = !0
				};
				return "function" == typeof t && t(function(o, r) {
					e(o, r), n.callback[o] = function() {
						t(e)
					}
				}), this
			};
		return r && (t = e, e = []), zs["layui.all"] || !zs["layui.all"] && zs["layui.mobile"] ? a.call(o) : (o.cite(e, a), o)
	},
	o.prototype.config = function(e){
		e = e || {};
		for(var t in e) n[t] = e[t];
		return this
	},o.prototype.extend = function(e){
		var t = this;
		e = e || {};
		for(var n in e) t[n] || t.modules[n] ? a("模块名 " + n + " 已被占用") : t.modules[n] = e[n];
		return t
	}, o.prototype.modules = function() {
		var e = {};
		for(var t in u) e[t] = u[t];
		return e
	}(),o.prototype.each = function(e, t){
		/**
		 * e: 需要遍历的对象
		 * t: 回调函数
		 */
		var n, o = this;
		if("function" != typeof t) return o;
		if(e = e || [], e.constructor === Object) {
			for(n in e)
				if(t.call(e[n], n, e[n])) break
		} else
			for(n = 0; n < e.length && !t.call(e[n], n, e[n]); n++);
		return o
	},n.callback = {},o.prototype.factory = function(e) {
        if(zs[e]) return "function" == typeof n.callback[e] ? n.callback[e] : null
    },o.prototype.objToUrl = function (e) {
        var a = [];
		return e != null ? function () {
            for (var i in e) {
                a.push(i + '=' + e[i]);
            }
            return a.join('&')
        }() : function () {
			return e;
        }();
    }, o.prototype.ajax = function (d) {
        // var xhr = null, o = this;
        // var e = {
			// type: arguments[0].type || 'post',
			// url: arguments[0].url || '',
			// async: arguments[0].async || true,
			// data: arguments[0].data || null,
			// dataType: arguments[0].dataType || 'json',
			// contentType: arguments[0].contentType || 'application/x-www-form-urlencoded',
			// beforeSend: arguments[0].beforeSend || function(){},
			// success: arguments[0].success || function () {},
			// error: arguments[0].error || function () {}
        // }
        // e.beforeSend();
        // if (window.ActiveXObject) {
        //     xhr = new ActiveXObject("Microsoft.XMLHTTP");
        // } else if (window.XMLHttpRequest) {
        //     xhr = new XMLHttpRequest();
        // }
        // xhr.responseType = e.dataType;
        // if (e.type == 'post'){
        //     xhr.open(e.type, e.url, e.async);
        //     xhr.setRequestHeader('Content-Type', e.contentType);
        //     xhr.send(o.objToUrl(e.data));
        // }else {
			// xhr.open(e.type, e.url+ '?'+ o.objToUrl(e.data), e.async);
        //     xhr.send();
        // }
        // xhr.onreadystatechange = function () {
			// if (xhr.readyState == 4) {
			// 	if (xhr.status == 200){
        //             e.success(xhr.response);
			// 	}else {
        //             e.error();
			// 	}
        //     }
        // }
        $.ajax({
            url: d.url,
            dataType: typeof d.dataType === 'undefined' ? 'json' :d.dataType,
            type: typeof d.type === 'undefined' ? 'post' : d.type,
            async: typeof d.async === 'undefined' ? true : false,
			cache: typeof d.cache === 'undefined' ? false : true,
            data: d.data || {},
            success: d.success,
            timeout: typeof d.timeout === 'undefined' ? 3000 : d.timeout,
            error: function () { console.log("请求失败!");}
        });
    }

	e.zs = new o
}(window);
